home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
sco5x
/
install
/
bin
/
stop_enl_daemons
< prev
Wrap
Text File
|
1998-07-01
|
3KB
|
156 lines
#!/bin/sh
#
# Script: stop_enl_daemons
#
# stop_enl_daemons stops all Enlighten daemons
# (emd, pep, renld, and Events)
#
# Note: I tried to use $* to pass "$procs" around, but
# SCO fails to deal with $* properly in the context of a function.
#
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
# All Rights Reserved.
# mrm July 23, 1997
#
PATH=/bin:/usr/bin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH
export PATH
#
# Display Usage
#
usage() {
echo "Usage: $appName"
}
#
# Put the pid(s) of process(es) from $procs into $pid
#
getPid() {
# Search for:
# .../bin/renld -v 0
# .. renld -v0
# renld
psList=`ps $PSOPTS | egrep -v "$appName|grep|stop_enl_daemons|start_enl_daemons|enl_post_install"`
pid=""
for i in $procs ; do
newpid=`echo "$psList" | egrep "\/$i | $i |[\/ ]$i$" | \
sed -e 's/^ *//' -e 's/ .*//'`
pid="$pid $newpid"
done
pid=`echo $pid`
}
#
# Kill process(es) in $procs.
#
killProcs() {
getPid $procs
if [ -n "$pid" ] ; then
if [ "$KILLOPTS" = "-9" -o "$KILLOPTS" = "-KILL" ] ; then
echo
echo "$appName: Killing the following processes:"
else
echo
echo "$appName: Stopping the following processes:"
fi
echo "$psList" | grep PID
for i in $pid ; do
echo "$psList" | egrep "^[ ]*$i "
kill $KILLOPTS $i
done
else
echo "$appName: No Enlighten daemons are active."
echo "$appName: Checking for licenseing daemons..."
fi
}
#
# Kill Stubborn processes in $procs
# killStubbornProc waits for WAIT_CYCLES before kill -KILL'ing.
#
killStubbornProcs() {
WAIT_CYCLES=${WAIT_CYCLES:-10}
cyclesWaited=0
$ECHO "$appName: Waiting for daemons to shut down.\c"
while [ $cyclesWaited -lt $WAIT_CYCLES ] ; do
cyclesWaited=`expr $cyclesWaited + 1`
sleep 1
getPid
if [ -z "$pid" ] ; then
break
else
$ECHO ".\c"
fi
done
echo
if [ $cyclesWaited -eq $WAIT_CYCLES ] ; then
KILLOPTS="-9"
killProcs
fi
}
#
# -=-=-=-=-=-=-=-= Start of Main Program -=-=-=-=-=-=-=-=-=-
#
appName=`basename $0`
#
# Ensure the user is root
#
USER_ID=`id | tr "\(" "=" | cut "-d=" -f2`
if [ ! $USER_ID = 0 ] ; then
echo "### $appName must be run by the 'root' superuser."
echo " Please su to root and try again."
exit 2
fi
#
# Deal with bsd ps
#
ECHO=echo
PSOPTS="-e"
PIDCOLUMN=1
OS=`uname -s`
REV=`uname -r`
export OPTS PIDCOLUMN ECHO pid psList procs
if [ "$OS" = "SunOS" ] ; then
case "$REV" in 4.1.* )
PSOPTS="-agxww"
if [ -x /usr/5bin/echo ] ; then
ECHO=/usr/5bin/echo
fi
;;
esac
fi
#
# Stop the daemons.
#
KILLOPTS="-15"
WAIT_CYCLES=10 # About 10 seconds.
procs="AgentMon renld pep emdd renldc AgentENL"
killProcs
getPid
if [ -n "$pid" ] ; then
killStubbornProcs
fi
echo "$appName: Finished."